


let request_key = 'ny_skill'
let skill_count_key = 'ny_skill_count'
let skill_name = 'skill_name'
!(async () => {
    if (typeof $request !== "undefined") {
  console.log(`开始获取请求参数`);
   get_request_key();
   let body = $response.body;
    body =  JSON.parse(body);
    if (body.info){
        body.info = "成功抓到请求，等待秒杀";
        console.log(body);
    }
    body =  JSON.stringify(body);
    $done({ body })
   $done();
}else {
    console.log(`开始执行请求`);
    let request_value = $store.get(request_key);
    if(request_value&&request_value!=""){
        //  $store.delete没有暴露出来，无法使用，兼容下
        $store.set(request_key, "")  
        let count = $store.get(skill_count_key);
        if (!count){
            $store.set(skill_count_key, 1)  
            count = 1
        }
        axios_skill(request_value,count);
    }
    }
    })()
   .catch((e) =>console.log(e))
   .finally(() =>$done())

function axios_skill(request_value,count){
    if(count>0){
        count--;
        $axios(request_value)
        .then(res=>{
            console.log('请求结果：');
            console.log(res.headers.date);
            console.log(res.data);
            let skill_name = $store.get(skill_name);
            $feed.push("农行秒杀结果：", skill_name+res.data.info)
            axios_skill(request_value,count)
        })
        .catch(e=>console.log(e.message));  
    }
  
}


function get_request_key() {
    $store.set(request_key, $request) 
}
